/**
 * 
 */
package com.simple.datax.schedule.impl;

import java.util.Date;

import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import com.simple.datax.SimpleObject;
import com.simple.datax.api.MessageProcessor;
import com.simple.datax.api.SimpleException;

/**
 * @author paladin
 * 
 */
@Component
public class AsyncWorker implements MessageProcessor {

	@Async
	@Override
	public void process(SimpleObject src) throws SimpleException {
		String threadName = Thread.currentThread().getName();
		System.out.println("   " + threadName + " beginning work on " + src +":"+ new Date());
		try {
			Thread.sleep(5000); // simulates work
		} catch (InterruptedException e) {
			Thread.currentThread().interrupt();
		}
		System.out.println("   " + threadName + " completed work on " + src +":"+ new Date());
	}

}
